package com.csii.security;

import com.csii.user.entity.SysUser;
import com.csii.user.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 通过手机号获取用户信息和权限资源
 * @Auther: ian
 */
@Component("mobileUserDetailsService") // 一定不要少了
public class MobileUserDetailsService extends AbstractUserDetailsService {

    @Autowired
    ISysUserService sysUserService;

    @Override
    public SysUser findSysUser(String usernameOrMobile) {
        if (usernameOrMobile == null){
            return null;
        }
        // 1. 通过手机号查询用户信息
        return sysUserService.getUserByPhone(usernameOrMobile);
    }

}